def2d8ab53606d4edf54f0b7203a805d35817f6a,python/src/com/jetbrains/python/actions/DocstringQuickFix.java,DocstringQuickFix,createMissingReplacement,#PsiElement#,97

Before Change


    PyFunction fun = PsiTreeUtil.getParentOfType(element, PyFunction.class);
    PsiWhiteSpace whitespace = PsiTreeUtil.getPrevSiblingOfType(fun.getStatementList(), PsiWhiteSpace.class);
    newText.deleteCharAt(newText.length()-1);
    newText.append((whitespace != null ? whitespace.getText() : "\n"));

    for (int i = 0; i != myMissing.size(); ++i) {
      String s = myMissing.get(i);

After Change


  private String createMissingReplacement(PsiElement element) {
    String text = element.getText();
    String[] lines = LineTokenizer.tokenize(text, true);
    StringBuilder newText = new StringBuilder();
    int ind = lines.length - 1;
    for (int i = 0; i != lines.length-1; ++i) {
      String line = lines[i];
      if (line.contains(myPrefix)) {
        ind = i;
        break;
      }
      newText.append(line);
    }
    PyFunction fun = PsiTreeUtil.getParentOfType(element, PyFunction.class);
    PsiWhiteSpace whitespace = PsiTreeUtil.getPrevSiblingOfType(fun.getStatementList(), PsiWhiteSpace.class);
    String ws = "\n";
    if (whitespace != null) {
      String[] spaces = whitespace.getText().split("\n");
      if (spaces.length > 1)
        ws = ws + whitespace.getText().split("\n")[1];
    }